<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2012.03.17.
   家居商家视频控制器($小牛New $2014.07.28)*/

!defined('Q_PATH') && exit;

class JiajuvideoController extends AController{

	public function init__(){
		$this->_arrNotMethod=array(
			'save_previewstatus',
			'save_preview',
			'view_preview',
			'foreverdelete_deep',
			'input_change_unique',
			'forbid',
			'resume',
			'clear_recycle',
			'save_sort',
		);
		
		parent::init__();
	}
	
	public function filter_(&$arrMap){
		$arrMap['A.jiajuvideo_title']=array('like',"%".Q::G('jiajuvideo_title')."%");
		$arrMap['A.jiajuvideo_description']=array('like',"%".Q::G('jiajuvideo_description')."%");
		$arrMap['A.jiajuvideo_viewnum']=array('egt',intval(Q::G('jiajuvideo_viewnum')));
		$arrMap['A.jiajucompany_id']=$GLOBALS['_company_']['jiajucompany_id'];
		
		// 添加时间
		$this->getTime_('A.create_dateline',$arrMap);
	}

	protected function AEditObject_($oModel){
		if(in_array($oModel->jiajuvideo_status,array(9,3)) || $oModel->jiajucompany_id!=$GLOBALS['_company_']['jiajucompany_id']){
			$this->E('你没有权限访问。');
		}
	}

	protected function AInsertObject_($oModel){
		// 商家&城市
		$oModel->jiajucompany_id=$GLOBALS['_company_']['jiajucompany_id'];
		$oModel->site_id=$GLOBALS['_company_']['site_id'];
		$oModel->province_id=$GLOBALS['_company_']['province_id'];
		$oModel->city_id=$GLOBALS['_company_']['city_id'];

		// 添加人
		$oModel->user_id=$GLOBALS['___login___']['user_id'];
		$oModel->jiajuvideo_username=$GLOBALS['___login___']['user_name'];
		$oModel->jiajuvideo_editusername=$GLOBALS['___login___']['user_name'];
		$oModel->jiajuvideo_edituserid=$GLOBALS['___login___']['user_id'];
	}

	protected function AUpdateObject_($oModel){
		// 更新人
		$oModel->jiajuvideo_editusername=$GLOBALS['___login___']['user_name'];
		$oModel->jiajuvideo_edituserid=$GLOBALS['___login___']['user_id'];

		// 修改后提交
		if($oModel->jiajuvideo_status==1){
			$oModel->jiajuvideo_status=11;
		}
	}

}
